<?php


namespace app\admin\controller;


use app\admin\model\AdminLoginLog;
use think\Controller;
use think\Request;

class LoginLog extends Controller {

    protected $middleware = [
        "CheckPermission",
        "Log"
    ];

    private $loginLogModel;
    public function initialize()
    {
        parent::initialize();
        $this->loginLogModel = new AdminLoginLog();
    }


    public function index(Request $request){

        $where = [];
        $params = $request->param();
        $sDate = isset($params['startDate']) ? trim($params['startDate']) : '';
        $eDate = isset($params['endDate']) ? trim($params['endDate']) : '';
        if($sDate!='' && $eDate!=''){
            $where[] = ['create_time', 'between time', [strtotime($sDate), strtotime($eDate)]];
        }

        $logs = $this->loginLogModel->getList($where,15,$params);

        return $this->view->fetch('index',['list'=>$logs,'total'=>$logs->total()]);
    }


}